package com.dxd.onlineshop.mapper;

import com.dxd.onlineshop.pojo.SystemSetting;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SystemSettingMapper {
    //获取所有设置
    @Select("SELECT * FROM system_settings")
    List<SystemSetting> getAllSettings();

    //获取特定设置
    @Select("SELECT * FROM system_settings WHERE `key` = #{key}")
    SystemSetting getSettingByKey(@Param("key") String key);

    //增加设置
    @Insert("INSERT INTO system_settings (`key`, value, type) VALUES (#{key}, #{value}, #{type})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertSetting(SystemSetting setting);

    //更新设置
    @Update("UPDATE system_settings SET value = #{value}, type = #{type} WHERE `key` = #{key}")
    int updateSetting(SystemSetting setting);
}